#include "designwindow.h"
#include <QGraphicsScene>
#include <QAbstractGraphicsShapeItem>

#include "sk_game_item.h"
#include "userdata.h"

DesignWindow::DesignWindow(QWidget *parent)
    :
    QGraphicsView(parent)
{
    setScene(new QGraphicsScene(this));
    _UD.dw = this;
}

DesignWindow::~DesignWindow()
{
    _UD.dw = 0;
}

void DesignWindow::updateScene(sk::GameItem * createdItem, bool isDrop)
{
    if (0 == createdItem)
    {
        return;
    }
    QGraphicsItem * g = createdItem->createSceneItem();
    if (g)
    {
        if (isDrop)
        {
            QAbstractGraphicsShapeItem * as = static_cast<QAbstractGraphicsShapeItem *>(g);
            as->setPen(QPen(Qt::darkYellow));
        }
        scene()->addItem(g);
    }
}
